<#--
* Checkbox 
-->
<#macro Checkbox path labelText=path  value=""  attributes=""> 
  <@spring.bind path/>
  <#assign id="${spring.status.expression?replace('[','')?replace(']','')}">
  <#assign isChecked = spring.contains(spring.status.value?default([""]), value)>
  <div class="layui-form-item">
      <div class="layui-input-block">
          <input type="checkbox" id="${id}" name="${spring.status.expression}" title="${labelText}" value="${value}" lay-skin="primary" lay-verify="${required}" lay-verType="tips" lay-reqText="请选择${labelText}"
          <#if isChecked> checked="checked"</#if> ${attributes}>
      </div>
  </div>
</#macro>

<#--
* CheckboxList
-->
<#macro CheckboxList path options labelText=path textField="0" valueField="1"  required="" attributes="">
    <@spring.bind path/>
    <div class="layui-form-item">
        <label class="layui-form-label">
            <#if required?contains("required")><b style="color:red;padding:2px;vertical-align: middle;">*</b></#if>${labelText}
        </label>
        <div class="layui-input-block">
            <#if options?has_content>
               <#if options?is_hash>
                     <#list options?keys as keyItem>
                         <#assign isSelected = spring.contains(spring.status.value?default("")?split(','), keyItem?html)>
                         <input type="checkbox" name="${spring.status.expression}" title="${options[keyItem]?html}" value="${keyItem?html}"
                             lay-verify="${required}" lay-verType="tips" lay-reqText="请选择${labelText}"
                             <#if isSelected>checked</#if> ${attributes}>
                     </#list>
                <#else>
                    <#list options as item>
                        <#assign isChecked = spring.contains(spring.status.value?default("")?split(','), item[valueField]?html)>
                        <input type="checkbox" name="${spring.status.expression}"  title="${item[textField]?html}" value="${item[valueField]?html}" lay-skin="primary"
                            lay-verify="${required}" lay-verType="tips" lay-reqText="请选择${labelText}" <#if isChecked> checked="checked"</#if>  ${attributes}>
                    </#list>
                </#if>
            <#else>
                <div style="color:red;line-height: 38px; font-weight: bold;">当前列表暂无数据！</div>
            </#if>
        </div>
    </div>
</#macro>